package com.celesea.auth.form.controller.resource;

import com.celesea.auth.dept.vo.DeptTreeVo;
import com.celesea.auth.user.entity.User;
import com.celesea.framework.util.CollectionKit;

/**
 * @author JackYuan
 * @create 2017-11-02 22:35
 */
public class NodeResource {

    public static final String DEPT = "dept";
    public static final String USER = "user";
    private String id;
    private String name;
    private String type;
    private boolean isLeaf;


    public NodeResource(DeptTreeVo dept) {
        this.id = dept.getId();
        this.name = dept.getName();
        this.type = DEPT;
        this.isLeaf = CollectionKit.isEmpty(dept.getChildren());
    }

    public NodeResource(User user) {
        this.id = user.getId();
        this.name = user.getName();
        this.type = USER;
        this.isLeaf = true;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isLeaf() {
        return isLeaf;
    }

    public void setLeaf(boolean leaf) {
        isLeaf = leaf;
    }
}
